package com.hup.joystick.view.main;

import com.hup.joystick.view.customView.DeviceStateView;
import com.hup.utils.swing.customView.HScrollPanel;
import com.hup.utils.swing.customView.ImageButton;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

/**
 * @author hugan
 * @date 2020/10/22
 */
public class MainForm {
    public JPanel root;

    public DeviceStateView btnDeviceState;
    /**
     * 刷新按钮,只有在错误时才出现
     */
    public ImageButton btnRefreshDeviceState;

    public ImageButton btnHide;
    public ImageButton btnSetting;
    public ImageButton btnExit;

    /**
     * 手动的启动/停止按钮;已被自动连接功能替代,组件被隐藏
     */
    public JButton btnStart;
    public JButton btnStop;

    public HScrollPanel spFunction;
    public JPanel pFunction;
    public JLabel txtLock;

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        root = new JPanel();
        root.setLayout(new GridBagLayout());
        root.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel1, gbc);
        btnSetting = new ImageButton();
        btnSetting.setIcon(new ImageIcon(getClass().getResource("/img/icon_setting.png")));
        btnSetting.setToolTipText("设置");
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        panel1.add(btnSetting, gbc);
        btnHide = new ImageButton();
        btnHide.setIcon(new ImageIcon(getClass().getResource("/img/icon_hide.png")));
        btnHide.setToolTipText("隐藏");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 0;
        panel1.add(btnHide, gbc);
        btnExit = new ImageButton();
        btnExit.setIcon(new ImageIcon(getClass().getResource("/img/icon_exit.png")));
        btnExit.setToolTipText("关闭");
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = 0;
        panel1.add(btnExit, gbc);
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel1.add(panel2, gbc);
        btnDeviceState = new DeviceStateView();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel2.add(btnDeviceState, gbc);
        btnRefreshDeviceState = new ImageButton();
        btnRefreshDeviceState.setIcon(new ImageIcon(getClass().getResource("/img/icon_refresh.png")));
        btnRefreshDeviceState.setToolTipText("刷新");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        panel1.add(btnRefreshDeviceState, gbc);
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridBagLayout());
        panel3.setVisible(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel3, gbc);
        btnStart = new JButton();
        btnStart.setText("启动");
        btnStart.setToolTipText("aa");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel3.add(btnStart, gbc);
        btnStop = new JButton();
        btnStop.setText("停止");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel3.add(btnStop, gbc);
        spFunction = new HScrollPanel();
        spFunction.setVerticalScrollBarPolicy(20);
        spFunction.setVerticalScrollSize(new Dimension(5, -1));
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(spFunction, gbc);
        spFunction.setBorder(BorderFactory.createTitledBorder(null, "配置", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new GridBagLayout());
        spFunction.setViewportView(panel4);
        pFunction = new JPanel();
        pFunction.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel4.add(pFunction, gbc);
        final FunctionPreviewItem nestedForm1 = new FunctionPreviewItem();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        pFunction.add(nestedForm1.$$$getRootComponent$$$(), gbc);
        final JPanel spacer1 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.VERTICAL;
        panel4.add(spacer1, gbc);
        txtLock = new JLabel();
        txtLock.setHorizontalAlignment(0);
        txtLock.setText("设备已锁定");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        root.add(txtLock, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return root;
    }

}
